import crypto from "crypto";

export default{
    install(Vue,options)
    {
        // 页面跳转函数
        Vue.prototype.goTo = function (location) {
            this.$router.push({ path: location })
        };
        // 登录通信加密函数
        Vue.prototype.get_signature = function (payload) {
            let nowDate = new Date();
            let crypto = require('crypto');
            let pre_signature = "";
            this.global.timestamp = nowDate.getTime();
            pre_signature = this.global.nonce + ":" + payload + ":" + this.global.secret + ":" + this.global.timestamp;
            this.global.webSignature = crypto.createHash('sha1')
                .update(pre_signature, 'utf8')
                .digest('hex');
        };
        // 弹窗函数 四种模式 success info warning error
        Vue.prototype.systemAlert = function (type,title,msg,time) {
            this.$notification[type]({
                message: title,
                description: msg,
                duration: time,
            })
        }
        // 打开简道云
        Vue.prototype.openJDY = function () {
            window.open('https://www.jiandaoyun.com/dashboard/');
        }
    }
}
